
const searchFormList = [
  { label: '', width: '130px', value: 'btnOperation', type: 'slot' },
	{ label: '关键词', value: 'query', type: 'input', width: '200px' },
  { label: '类别', value: 'ostype', type: 'select', width: '200px', option: 'gcTagOstype', filterable: true,  clearable: true},
	{ label: '', width: '200px', value: 'btnSearch', type: 'slot' }
];

const tables = [ // 表格数据
  { label: '记录ID', value: 'id', sort:'custom'},
  { label: '分组PID', value: 'pid'},
  { label: '名称', value: 'name'},
  { label: '图标', value: 'icon', type: 'slot'},
  { label: '添加用户', value: 'userid', type: 'slot'},
  { label: '类别', value: 'ostype', type: 'slot'},
  { label: '标签介绍', value: 'datas'},
  { label: '统计数值', value: 'stats', width:70},
  { label: '更新时间', value: 'stime'}
];

const fieldList = [ // 新增弹出数据
  { label: '名称', value: 'name', type: 'input', width: '300px'},
  { label: '图标', value: 'icon', type:'file', width: '300px', accept:'image/jpeg,image/gif,image/png', multiple:false, data:{skey:'file',appdir:'tag'}},
  { label: '类别', value: 'ostype', type:'select', width: '300px', option: 'gcTagOstype', filterable: true, className:''},
  { label: '介绍', value: 'datas', type: 'textarea', width: '420px', autosize:{minRows: 6, maxRows: 1000}}
];

const rules = {
	name: [{ required: true, message: '请输入名称', trigger: 'change' }],
  datas: [{ required: true, message: '请设置标签介绍', trigger: 'change' }],
  ostype: [{ required: true, message: '请选择标签类别', trigger: 'change' }]
};

const fieldData = (data)=>{
  var dataset = {};
  for (var idx = 0; idx < fieldList.length; idx++) {
    var ckey  = fieldList[idx].value;
    dataset[ckey] = (data)? data[ckey]:'';
  }
  dataset.id = (data && data.id)? data.id:0;
  return dataset;
}

export default {
  searchFormList,tables,fieldList,fieldData,rules
};